#include "kshapesvgfactory.h"
#include <QDebug>
#include "kexportshape.h"
#include "kshapeutils.h"
#include "kexportshape.h"


KExportShape* KShapeSvgFactory::createShapeFromSvg(const QDomElement& elem)
{
    if (elem.tagName() == "rect" && elem.attribute("id") == "canvas_background")
        return nullptr;

    if (elem.tagName() == "g")
        return nullptr;

    KShapeType type;
    KShapeUtils utils;
    if (!utils.tagToShapeType(elem.tagName(), type,elem)) {
        qWarning() << "[KShapeSvgFactory] Unknown tag:" << elem.tagName();
        return nullptr;
    }
    KExportShape* shape = createShape(type);
    if (!shape) return nullptr;
    shape->loadFromSvgElement(elem);
    return shape;
}
